package xyz.syyrjx.controller;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.syyrjx.entity.Order;
import xyz.syyrjx.entity.ResultInfo;
import xyz.syyrjx.entity.User;
import xyz.syyrjx.service.OrderService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Mr.Wan
 * @date 2022/10/11 - 20:20
 */
@RestController
public class MysqlOrderController {
    
    @Resource
    private OrderService orderService;

    @RequestMapping("/order/getSelf")
    public ResultInfo<List<Order>> getOrderSelf(@RequestBody User user){
        try {
            List<Order> orderList = orderService.getOrderByUer(user);
            return ResultInfo.success(orderList);
        }catch (Exception e){
            return ResultInfo.fail(e.getMessage());
        }
    }
}
